package com.mtao.controller;

import com.mtao.*;
import com.mtao.dto.ProductDto;
import com.mtao.dto.ProductTypeDto;
import com.mtao.entity.Result;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/wx")
public class WxProductController {

    @Resource
    private ProductService productService;

    /**
     * 获取每日推荐
     * @param
     * @return
     */

    @PostMapping("/daily/recommendation")
    public com.mtao.entity.Result getEverDayProduct(){
//        SELECT * FROM my_table
//        ORDER BY timestamp_column DESC
//        LIMIT 3;
        return null;
    }
    /**
     * 获取商品类型
     * @param
     * @return
     */

    @PostMapping("/product/type/list")
    private com.mtao.entity.Result getProductType(@RequestBody(required = false) @Validated(ProductTypeDto.Search.class) ProductTypeDto productTypeDto) {
        if(productTypeDto==null){
            List<com.mtao.entity.ProductType> list=productService.getProductTypeAllList();
            return com.mtao.entity.Result.success(list);
        }
        PageBean<com.mtao.entity.ProductType> list = productService.getProductTypeList(productTypeDto);
        return com.mtao.entity.Result.success(list);
    }
    /**
     *  商品列表
     * @param
     * @return
     */

    @PostMapping("/product/list")
    private com.mtao.entity.Result<PageBean<com.mtao.entity.Product>> getProduct(@RequestBody @Validated(ProductDto.Add.class) ProductDto productDto) {
        PageBean<com.mtao.entity.Product> list = productService.getProductList(productDto);
        return Result.success(list);
    }
}
